<%@taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<%@taglib uri="http://www.springframework.org/tags/form" prefix="form" %>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>

<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<title>Track My Budget - Contact Manager | trackmybudget.com</title>
	<link rel="stylesheet" type="text/css" href="<c:url value="/static/resources/css/screen.css"/>"/>
</head>
<body>
	<div id="container">
		<div class="dualbrand">
			<img src="<c:url value="/static/resources/gfx/dualbrand_logo.png"/>"/>
		</div>
		
		<div id="content">
			<h2>Contact Manager</h2>
			
			<form:form method="POST" action="add.html" commandName="contact">
				<form:errors path="*" class="validation" element="div" />
				<table>
					<tbody>
						<tr>
							<td><form:label path="firstName"><spring:message code="label.firstname"/></form:label>
							<td><form:input path="firstName"/></td>
							<!-- <td><form:errors class="invalid" path="firstName"/></td> -->
						</tr>
						<tr>
							<td><form:label path="lastName"><spring:message code="label.lastname"/></form:label>
							<td><form:input path="lastName"/></td>
							<!-- <td><form:errors class="invalid" path="lastName"/></td> -->
						</tr>
						<tr>
							<td><form:label path="phone"><spring:message code="label.phone"/></form:label>
							<td><form:input path="phone"/></td>
							<!-- <td><form:errors class="invalid" path="phone"/></td> -->
						</tr>
						<tr>
							<td><form:label path="mobile"><spring:message code="label.mobile"/></form:label>
							<td><form:input path="mobile"/></td>
							<!-- <td><form:errors class="invalid" path="mobile"/></td> -->
						</tr>
						<tr>
							<td><form:label path="email"><spring:message code="label.email"/></form:label>
							<td><form:input path="email"/></td>
							<!-- <td><form:errors class="invalid" path="email"/></td> -->
						</tr>
						<tr>
							<td colspan="2">
								<input type="submit" value=<spring:message code="label.addcontact"/>>
							</td>
						</tr>
					</tbody>
				</table>
			</form:form>
			
			<h3>Contacts</h3>
			<c:choose>
				<c:when test="${contactList.size()==0}">
					<em>No registered contacts.</em>
				</c:when>
				<c:otherwise>
					<table class="simpletablestyle">
						<thead>
							<tr>
								<th>Name</th>
								<th>Phone</th>
								<th>Mobile</th>
								<th>Email</th>
								<th>&nbsp;</th>
							</tr>
						</thead>
						<tbody>
							<c:forEach items="${contactList}" var="contact">
								<tr>
									<td>${contact.lastName}, ${contact.firstName}</td>
									<td>${contact.phone}</td>
									<td>${contact.mobile}</td>
									<td>${contact.email}</td>
									<td><a href="delete/${contact.id}">delete</a></td>
								</tr>
							</c:forEach>
						</tbody>
					</table>
				</c:otherwise>
			</c:choose>
		</div>
		<div id="footer">
			<p><spring:message code="label.footer"/></p>
		</div>
	</div>
</body>
</html>